
function initExt(viewModel, requestUtils) {

    // 在这里写业务逻辑
    // cb.utils.alert("测试详情业务逻辑")
    viewModel.get("actual_modify").on('afterValueChange', function (data) {

        debugger
        let value = data.value || 0;
        // 下拨预算
        let budget = viewModel.get("budget").getValue() || 0;
        // 实际占用
        let actual_occupy = viewModel.get("actual_occupy").getValue() || 0
        // 经费总额
        let total_budget = budget + value
        // 实际可用
        let actual_budget = total_budget - actual_occupy
        viewModel.get("total_budget").setValue(total_budget)
        viewModel.get("actual_budget").setValue(actual_budget)

    })

    viewModel.get("budget").on('afterValueChange', function (data) {

        debugger
        // 下拨预算
        let budget = viewModel.get("budget").getValue() || 0;
        // 实际占用
        let actual_occupy = viewModel.get("actual_occupy").getValue() || 0

        let actual_modify = viewModel.get("actual_modify").getValue() || 0
        // 经费总额
        let total_budget = budget + actual_modify
        // 实际可用
        let actual_budget = total_budget - actual_occupy
        viewModel.get("total_budget").setValue(total_budget)
        viewModel.get("actual_budget").setValue(actual_budget)

    })



};



cb.define(process.env.__DOMAINKEY__, ['common/requestUtils.js'], function (requestUtils) {
    let vm = {
        doAction: function (name, viewModel) {
            if (this[name])
                this[name](viewModel);
        },
        init: function (viewModel) {
            initExt(viewModel, requestUtils);
        }
    }
    try {
        module.exports = vm;
    } catch (error) {
        console.log(error);
    }
    return vm;
});